<!DOCTYPE html>
<html>

<head>
    <#include "/xhc/admin/components/meta.html" />
    <title>出出帮火车奇妙世界后台 ${metaTitleSuffix!}</title>
    <#include "/xhc/admin/components/stylesheets.html" />
</head>

<body>
    <div id='app'>
        <el-container>
            <#assign menuIndex="2-1" />
            <#include "/xhc/admin/components/menu.html" />
            <el-container>
                <#include "/xhc/admin/components/header.html" />
                <el-main>
                    <template>
                        订单时间:
                        <el-date-picker v-model="date" type="datetimerange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd HH:mm:ss" @change="onDateChange" unlink-panels="true">
                        </el-date-picker>
                        进场时间:
                        <el-date-picker v-model="indate" type="datetimerange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd HH:mm:ss" @change="onInDateChange" unlink-panels="true">
                        </el-date-picker>
                        <el-button size='small' @click='download'>下载</el-button>
                        <el-table :data="items" style="width: 100%">
                            <el-table-column prop="addTime" label="日期" sortable>
                            </el-table-column>
                            <el-table-column prop="no" label="订单号" sortable>
                            </el-table-column>
                            <el-table-column prop="time" label="场次" sortable>
                            </el-table-column>
                            <el-table-column prop="out_trade_no" label="订单号" sortable>
                            </el-table-column>
                            <el-table-column prop="name" label="姓名" sortable>
                            </el-table-column>
                            <el-table-column prop="mobile" label="电话" sortable>
                            </el-table-column>
                            <el-table-column prop="nickname" label="微信">
                            </el-table-column>
                            <el-table-column prop="status" label="状态" sortable>
                                <template slot-scope="scope">
                                    <span v-if='scope.row.status ==-1'>已退款</span>
                                    <span v-if='scope.row.status ==0'>未支付</span>
                                    <span v-if='scope.row.status ==1'>已支付</span>
                                </template>
                            </el-table-column>
                            <!-- <el-table-column prop="type" label="类型">
            </el-table-column> -->
                            <el-table-column prop="isUsed" label="使用状态" sortable>
                                <template slot-scope="scope">
                                    <span v-if='scope.row.isUsed ==0'>未使用</span>
                                    <span v-if='scope.row.isUsed ==1'>已使用</span>
                                </template>
                            </el-table-column>
                            <el-table-column prop="inTime" label="进场时间" sortable>
                            </el-table-column>
                            <el-table-column prop="outTime" label="出场时间" sortable>
                            </el-table-column>
                            <el-table-column prop="duration" label="停留分钟" sortable>
                            </el-table-column>
                            <el-table-column label="操作">
                                <template slot-scope="scope">
                                    <el-button size='small' @click=onUpdateOrder(scope.row)>更新</el-button>
                                    <el-button v-if='scope.row.status ==1' size='small' @click=onRefund(scope.row)> 退款</el-button>
                                </template>
                            </el-table-column>
                        </el-table>
                        <#include '/components/page.html' />
                    </template>
                </el-main>
            </el-container>
        </el-container>
        ${inStartDate!}
        <#include "/xhc/admin/components/footer.html" />
    </div>
    <#include "/xhc/admin/components/scripts.html" />
    <script type="text/javascript">
    var vue = new Vue({
        el: '#app',
        data() {
            return {
                date: ['${startDate!}', '${endDate!}'],
                indate: [],
                items: toJson(`${data![]}`),
            }
        },
        mounted: function() {
            var dt = ['${inStartDate!}', '${inEndDate!}']
            if (dt[0] != '') {
                this.indate = dt
            }
        },
        methods: {
            download() {
                goDownload()
            },
            onRefund(info) {
                this.$confirm('确定退款?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    var param = {
                        id: info.id
                    }
                    axiosRequest(param, '/xhc/web/order/redunTicket', '')
                }).catch(() => {});
            },
            onUpdateOrder(info) {
                var param = {
                    orderId: info.orderId
                }
                axiosRequest(param, '/xhc/web/order/updateOrder', '')
            },
            onDateChange(val) {
                if (val == null) {
                    var keys = [
                        { key: 'startDate', value: '' },
                        { key: 'endDate', value: '' }
                    ]
                    goPage(1, keys)
                } else {
                    var keys = [
                        { key: 'startDate', value: val[0] },
                        { key: 'endDate', value: val[1] }
                    ]
                    goPage(1, keys)

                }
            },
            onInDateChange(val) {
                if (val == null) {
                    var keys = [
                        { key: 'inStartDate', value: '' },
                        { key: 'endDate', value: '' }
                    ]
                    goPage(1, keys)
                } else {
                    var keys = [
                        { key: 'inStartDate', value: val[0] },
                        { key: 'inEndDate', value: val[1] }
                    ]
                    goPage(1, keys)
                }
            },
        },
        filters: {
            fmt(date) {
                return date
            }
        }
    })
    </script>
    <script> 
    </script>
</body>

</html>